perm filename BYTE6.SAI[SAI,LES] blob
sn#742025 filedate 1984-02-08 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 begin "byte6"
C00006 ENDMK
C⊗;
begin "byte6"
require "[]<>" delimiters;
define !=[Comment], LN=[length], PROC=[simple procedure], SAY=[outstr],
THRU=[step 1 until], EXIT=[quick_code calli '12 end];
proc explain; begin
say("To type a binary file in 6-bit slices as ASCII, with 48 (decimal) added
to each slice, say
.R BYTE6 ;<file name>
It will type ""#"" followed by a string of ASCII characters representing the
bit slices. After each block of 150 characters (i.e. 25 words) or end-of-file,
whichever comes first, the ASCII character ""#"" is sent followed by six
characters of checksum (based on 36-bit twos complement addition) is sent in the
same 6 slice form as data words. At the end of the file, a ""."" is sent
followed the number of words, given as a 36-bit word sent in the same 6 slice
form. If any character code below decimal 48 other than ""#"" or ""."" is
received, the transmission has been garbled.
");
exit;
end;
proc out6(integer word); begin ! slice word into 6 6-bit slices & output;
integer b; ! 6-bit group #;
for b←1 thru 6 do outchr(((word←word rot 6)land '77)+'60);
end;
integer inch,brk,eof,fl; ! IO globals;
integer data,wordcount,checksum; ! binary word, # words sent, block checksum;
string file;
backup; ! prepare to read the command line;
setbreak(1,";","","IS");
scan(file←inchwl,1,brk); ! skip everything to the left of the semicolon;
if ln(file)=0 then explain; ! no file name given;
open(inch←getchan,"DSK",'10,19,0,400,brk,eof);
lookup(inch,file,fl);
if fl then begin print("File ",file," not found."&'15&'12); explain end;
outchr("#");
wordcount←0;
data←wordin(inch); ! read first word;
while not eof do begin
integer i;
checksum←0;
for i←0 step 1 while i<25 and not eof do begin
checksum←checksum+data;
out6(data); ! output 6 slices;
data←wordin(inch);
end;
wordcount←wordcount+i;
outchr("#"); ! output checksum for block;
out6(checksum);
end;
outchr(".");
out6(wordcount);
exit
end